import { Controller, Get, Query } from "@nestjs/common";
import { EproxyService } from "./eproxy.service";
import ClashHelper from "../clash/clash.helper";

@Controller("eproxy")
export class EproxyController {
  constructor(
    private readonly eproxyService: EproxyService
  ) {}

  @Get("get")
  getProxy(@Query() query: {id: string}) {
    return ClashHelper.getNext(query.id)
  }

  @Get("config/debug")
  debug() {
    return ClashHelper.debug()
  }

  

  @Get("config/getAll")
  getAll() {
    return ClashHelper.proxies.filter(e => e.delayRes?.status)
  }

  @Get("config/refresh")
  refreshConfigs() {
    return ClashHelper.refreshConfig()
  }
  @Get("config/delay/check")
  checkDelay(@Query() query: {id: string}) {
    return this.eproxyService.getProxy(query.id)
  }
}